package com.develop.alarm.service;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.Producer;
import org.apache.kafka.clients.producer.ProducerRecord;

import com.develop.common.PropertiesUtils;

import java.util.Properties;
 
public class AlarmProducer {
  public static void main(String[] args) {
    Properties props = new Properties();
    props.put("bootstrap.servers", PropertiesUtils.getPropertiesByKey("kafka.producer.servers", "application.properties"));
    props.put("acks", "all");
    props.put("retries", 0);
    props.put("batch.size", 16384);
    props.put("linger.ms", 1);
    props.put("buffer.memory", 33554432);
    props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
    props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
 
    Producer<String, String> producer = new KafkaProducer<>(props);
    String value="";
    for(int i = 1; i <= 2; i++){
      
       value ="{\"alarmSeq\":"+i+",\"alarmTitle\":\"小区无话务量告警\",\"alarmStatus\":1,\"alarmType\":\"Signaling System\",\"origSeverity\":3,\"eventTime\":\"2016-04-14 16:25:42\",\"omcReceivedTime\":\"2016-04-14 16:25:43\",\"alarmId\":\"352135\",\"specificProblem\":\"\",\"specificProblemID\":\"29242\",\"omcUID\":\"10100MOBILE0008A \",\"neUID\":\"DC=www.excample.cn,SubNetwork=EG_EUTRAN_SYSTEM,SubNetwork=0,ManagedElement=2,EnbFunction=1\",\"neName\":\"LTE北向基站\",\"neType\":\"ENB\",\"objectUID\":\"NE=528,eNodeBCell=0\",\"objectName\":\"小区0\",\"objectType\":\"EutranCellTdd\",\"locationInfo\":\"本地小区标识=0, 小区双工模式=0, 检测时长（小时）=0, 小区名称=please replace, eNodeB标识=0,小区标识=0\",\"eSerialNum\":\"ABCD1234EFGH1234\",\"addInfo\":\"eNodeBId=490937\",\"rNeUID\":\" NE=001\",\"rNeName\":\"BBU金融街\",\"rNeType\":\"BBU-CU\"}";
//       value ="{\"alarmSeq\":"+i+",\"alarmTitle\":\"小区无话务量告警\",\"alarmStatus\":1,\"alarmType\":\"Signaling System\",\"origSeverity\":3,\"eventTime\":\"2016-04-14 16:25:42\",\"omcReceivedTime\":\"2016-04-14 16:25:43\",\"alarmId\":\"352135\",\"specificProblem\":\"\",\"specificProblemID\":\"29242\",\"omcUID\":\"10100MOBILE0008A \",\"neUID\":\"DC=www.excample.cn,SubNetwork=EG_EUTRAN_SYSTEM,SubNetwork=0,ManagedElement=2,EnbFunction=1\",\"neName\":\"LTE北向基站\",\"neType\":\"ENB\",\"objectUID\":\"NE=528,eNodeBCell=0\",\"objectName\":\"小区0\",\"objectType\":\"EutranCellTdd\",\"locationInfo\":\"本地小区标识=0, 小区双工模式=0, 检测时长（小时）=0, 小区名称=please replace, eNodeB标识=0,小区标识=0\",\"eSerialNum\":\"ABCD1234EFGH1234\",\"addInfo\":\"eNodeBId=490937\"}";
       producer.send(new ProducerRecord<>(PropertiesUtils.getPropertiesByKey("kafka.producer.topic", "application.properties"), Integer.toString(i), value));
  }
    System.out.println("数据生成完成");
    producer.close();
}
}